Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: HeaderMap::reserve allocates insufficient capacity #741

Merged
merged 2 commits into from
Jan 10, 2025

Conversation

kawaemon
Copy link
Contributor

@kawaemon kawaemon commented Jan 8, 2025

Current implementation of HeaderMap::reserve actually reserves less capacity than requested, causing reallocation when attempted to insert the requested number of entries.

This PR adds a test, then fixes it by converting requested capacity to raw one before allocation.

This bug caused additional allocation when attempted to insert
the requested number of entries.
This commit fix that by converting capacity to raw capacity before
allocation.
Copy link
Member

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement, thank you!

@seanmonstar seanmonstar merged commit 68845bd into hyperium:master Jan 10, 2025
10 checks passed
@kawaemon kawaemon deleted the fix-realloc branch January 11, 2025 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants